USE ConsultTracking
go
-------------------------------------------------
--Create Customer
DECLARE @CustomerName nvarchar(100)
DECLARE @Phone nvarchar(100)
DECLARE @Fax nvarchar(100)
DECLARE @CustomerID int
DECLARE @Active bit
DECLARE @Created smalldatetime
DECLARE @Modified smalldatetime

DECLARE @Modified1 smalldatetime

SET @CustomerName = 'The Really F''ing Big Customer Name that is about to be changed'
SET @Phone = '867-5309'
SET @Fax = 'Did you catch the reference'

EXECUTE [ConsultTracking].[dbo].[CreateCustomer] 
   @CustomerName
  ,@Phone
  ,@Fax
	,@CustomerID 
	,@Active 
	,@Created 
	,@Modified out

SET @Modified1 = @Modified

SET @CustomerName = 'Non-Active Customer'
SET @Phone = '000-000-0000'
SET @Fax = '111-111-1111'

EXECUTE [ConsultTracking].[dbo].[CreateCustomer] 
   @CustomerName
  ,@Phone
  ,@Fax
	,@CustomerID 
	,@Active 
	,@Created 
	,@Modified 
-------------------------------------------------
--  Update Customer

SET @CustomerID = 1
SET @CustomerName = 'Test Co'
SET @Phone = '555-555-5555'
SET @Fax = '444-444-4444'
SET @Active = 1
SET @Modified = @Modified1

EXECUTE [ConsultTracking].[dbo].[UpdateCustomer] 
   @CustomerID
  ,@CustomerName
  ,@Phone
  ,@Fax
  ,@Active
  ,@Modified

-------------------------------------------------
-- Insert Purpose Types
GO
INSERT INTO [ConsultTracking].[dbo].[PurposeType]
           ([Name],[Description])
     VALUES
           ('Billing','Used for sending bills to the Customer')
INSERT INTO [ConsultTracking].[dbo].[PurposeType]
           ([Name],[Description])
     VALUES
           ('Business','This should be one of the customers main locations and used for PR type things')
INSERT INTO [ConsultTracking].[dbo].[PurposeType]
           ([Name],[Description])
     VALUES
           ('Alternate','This could be a satelite or other location where work for the customer is done')
INSERT INTO [ConsultTracking].[dbo].[PurposeType]
           ([Name],[Description])
     VALUES
           ('Emergency','This is reserved for emergency situations')
-------------------------------------------------
--  Create Location
GO
DECLARE @CustomerID int
DECLARE @LocationName nvarchar(50)
DECLARE @Address1 nvarchar(500)
DECLARE @Address2 nvarchar(50)
DECLARE @City nvarchar(100)
DECLARE @State nvarchar(30)
DECLARE @Zip nvarchar(10)
DECLARE @PurposeTypeID int

SET @CustomerID = 1
SET @LocationName = 'Run Down Office That Should be Condemed'
SET @Address1 = 'Has anyone actually read this?'
SET @Address2 = 'How can you have suites when you don''t even have walls walls'
SET @City = 'Freakville'
SET @State = 'Insanity'
SET @Zip = '66666'
SET @PurposeTypeID  = 1

EXECUTE [ConsultTracking].[dbo].[CreateLocation] 
   @CustomerID
  ,@LocationName
  ,@Address1
  ,@Address2
  ,@City
  ,@State
  ,@Zip
  ,@PurposeTypeID
-------------------------------------------------
-- Update Location
DECLARE @LocationID int

SET @LocationID = 1
SET @LocationName = 'Main Office'
SET @Address1 = '123 Main St'
SET @Address2 = 'Suite A-1'
SET @City = 'Bellevue'
SET @State = 'Washington'
SET @Zip = '98007'

EXECUTE [ConsultTracking].[dbo].[UpdateLocation] 
   @LocationID
  ,@LocationName
  ,@Address1
  ,@Address2
  ,@City
  ,@State
  ,@Zip
-------------------------------------------------
--  Create Contact
GO
DECLARE @FirstName nvarchar(50)
DECLARE @LastName nvarchar(50)
DECLARE @OfficePhone nvarchar(50)
DECLARE @MobilePhone nvarchar(50)
DECLARE @Email nvarchar(100)
DECLARE @WorkLocationID int
DECLARE @CustomerID int
DECLARE @PurposeTypeID int
DECLARE @PurposeDescription nvarchar(200)

SET @FirstName = 'Dat Dang'
SET @LastName = 'Ho'
SET @OfficePhone = '666-666-6666'
SET @MobilePhone = '867-5309'
SET @Email = 'datho@thereallyfingbigcustomernamethatsabouttobechanged.com'
SET @WorkLocationID = 1
SET @CustomerID = 1
SET @PurposeTypeID = 1
SET @PurposeDescription = 'She has no purpose. I just had to type something in here so I could see it change.'

EXECUTE [ConsultTracking].[dbo].[CreateContact] 
   @FirstName
  ,@LastName
  ,@OfficePhone
  ,@MobilePhone
  ,@Email
  ,@WorkLocationID
  ,@CustomerID
  ,@PurposeTypeID
  ,@PurposeDescription
------------------------------------------------
--  Update Contact
DECLARE @ContactID int

SET @ContactID = 1
SET @FirstName = 'John'
SET @LastName = 'Doe'
SET @OfficePhone = '555-555-5555'
SET @MobilePhone = '123-456-7890'
SET @Email = 'john.doe@testcocom'
SET @WorkLocationID = 1

EXECUTE [ConsultTracking].[dbo].[UpdateContact] 
   @ContactID
  ,@FirstName
  ,@LastName
  ,@OfficePhone
  ,@MobilePhone
  ,@Email
  ,@WorkLocationID
--------------------------------------------------